<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>常用请求方法和数据提交</title>
    <style>
        table {
            border: 1px solid gray;
            text-align: center;
            vertical-align: middle;
            border-collapse: collapse;
        }

        th,
        td {
            border: 1px solid gray;
            padding: 5px 30px;
        }

        th {
            background-color: rgb(253, 84, 84);
            color: white;
        }

        tr:nth-child(2n+1) {
            background-color: #d4d1d1;
        }
    </style>
</head>

<body>
    <table>
        <tr>
            <th>请求方法</th>
            <th>操作</th>
        </tr>
        <tr>
            <td>GET</td>
            <td>获取数据</td>
        </tr>
        <tr>
            <td>POST</td>
            <td>提交数据</td>
        </tr>
        <tr>
            <td>PUT</td>
            <td>修改数据（全部）</td>
        </tr>
        <tr>
            <td>DELETE</td>
            <td>删除数据</td>
        </tr>
        <tr>
            <td>PATCH</td>
            <td>修改数据(部分)</td>
        </tr>
    </table>
    <button>注册</button>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script>
        document.querySelector('button').addEventListener('click', () => {
            axios({
                url: 'http://hmajax.itheima.net/api/register',
                method: 'POST',
                data: {
                    username: 'NingChe210307',
                    password: '123456'
                }
            }).then(result => console.log(result))
        })
    </script>
</body>

</html>